<?php


namespace App\Console\Commands;


use App\Models\Ca\Customer;
use Illuminate\Console\Command;

class ToPublicCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:toPublic';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '将客户加入公海';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
//        $date = date('Y-m-d');
//        //将超时未回访的客户加入公海
//        Customer::query()
//            ->where('hf_time', '<', $date)
//            ->where('last_visit_user_id', '=', 0)
//            ->update([
//                'is_public' => true
//            ]);
//        //标记未设置回访时间的客户
//        $date = date('Y-m-d', strtotime('-3 day'));
//        Customer::query()->where('created_at', '<', $date)
//            ->where('last_visit_user_id', '=', 0)
//            ->update([
//                'is_public' => true
//            ]);
        $date = date('Y-m-d', strtotime('-45 day'));
        Customer::query()->where('last_visit_time', '<', strtotime($date))
            ->where('last_visit_user_id', '=', 0)
            ->update([
                'is_public' => true
            ]);

    }
}